/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package py.una.pol.ii.is2.domain.flota;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author markos
 */
@Entity
@Table(name = "vehiculo_plantilla")
@NamedQueries({@NamedQuery(name = "VehiculoPlantilla.findAll", query = "SELECT v FROM VehiculoPlantilla v"), @NamedQuery(name = "VehiculoPlantilla.findByVeplKilometrajeFaltante", query = "SELECT v FROM VehiculoPlantilla v WHERE v.veplKilometrajeFaltante = :veplKilometrajeFaltante"), @NamedQuery(name = "VehiculoPlantilla.findByVeplVehiculo", query = "SELECT v FROM VehiculoPlantilla v WHERE v.vehiculoPlantillaPK.veplVehiculo = :veplVehiculo"), @NamedQuery(name = "VehiculoPlantilla.findByVeplPlantilla", query = "SELECT v FROM VehiculoPlantilla v WHERE v.vehiculoPlantillaPK.veplPlantilla = :veplPlantilla")})
public class VehiculoPlantilla implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected VehiculoPlantillaPK vehiculoPlantillaPK;
    @Basic(optional = false)
    @Column(name = "vepl_kilometraje_faltante")
    private Long veplKilometrajeFaltante;
    @JoinColumn(name = "vepl_plantilla", referencedColumnName = "plma_cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private PlantillaMantenimiento plantillaMantenimiento;
    @JoinColumn(name = "vepl_vehiculo", referencedColumnName = "vehi_cod", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Vehiculo vehiculo;

    public VehiculoPlantilla() {
    }

    public VehiculoPlantilla(VehiculoPlantillaPK vehiculoPlantillaPK) {
        this.vehiculoPlantillaPK = vehiculoPlantillaPK;
    }

    public VehiculoPlantilla(VehiculoPlantillaPK vehiculoPlantillaPK, Long veplKilometrajeFaltante) {
        this.vehiculoPlantillaPK = vehiculoPlantillaPK;
        this.veplKilometrajeFaltante = veplKilometrajeFaltante;
    }

    public VehiculoPlantilla(int veplVehiculo, int veplPlantilla) {
        this.vehiculoPlantillaPK = new VehiculoPlantillaPK(veplVehiculo, veplPlantilla);
    }

    public VehiculoPlantillaPK getVehiculoPlantillaPK() {
        return vehiculoPlantillaPK;
    }

    public void setVehiculoPlantillaPK(VehiculoPlantillaPK vehiculoPlantillaPK) {
        this.vehiculoPlantillaPK = vehiculoPlantillaPK;
    }

    public Long getVeplKilometrajeFaltante() {
        return veplKilometrajeFaltante;
    }

    public void setVeplKilometrajeFaltante(Long veplKilometrajeFaltante) {
        this.veplKilometrajeFaltante = veplKilometrajeFaltante;
    }

    public PlantillaMantenimiento getPlantillaMantenimiento() {
        return plantillaMantenimiento;
    }

    public void setPlantillaMantenimiento(PlantillaMantenimiento plantillaMantenimiento) {
        this.plantillaMantenimiento = plantillaMantenimiento;
    }

    public Vehiculo getVehiculo() {
        return vehiculo;
    }

    public void setVehiculo(Vehiculo vehiculo) {
        this.vehiculo = vehiculo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vehiculoPlantillaPK != null ? vehiculoPlantillaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof VehiculoPlantilla)) {
            return false;
        }
        VehiculoPlantilla other = (VehiculoPlantilla) object;
        if ((this.vehiculoPlantillaPK == null && other.vehiculoPlantillaPK != null) || (this.vehiculoPlantillaPK != null && !this.vehiculoPlantillaPK.equals(other.vehiculoPlantillaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.una.pol.ii.is2.dao.flota.VehiculoPlantilla[vehiculoPlantillaPK=" + vehiculoPlantillaPK + "]";
    }

}
